using System;
using FluentNHibernate.Automapping;
using FluentNHibernate.Automapping.Alterations;
using MvcMall.Core.Domains;
using MvcMall.Core.Enums;

namespace MvcMall.Data.NHibernateMaps
{
    public class GoodsMap : IAutoMappingOverride<Goods>
    {
        public void Override(AutoMapping<Goods> mapping)
        {
            mapping.Table("Goods");
            mapping.Map(c => c.FreightType).CustomType(typeof(FreightType));
            mapping.Map(c => c.GoodsType).CustomType(typeof(GoodsType));

            mapping.References(c => c.Country).Column("Country");
            mapping.References(c => c.Province).Column("Province");
            mapping.References(c => c.City).Column("City");

            mapping.References(c => c.Store).Column("StoreId");
            mapping.References(c => c.GoodsCategory).Column("GoodsCategoryId");
            mapping.References(c => c.GoodsBrand).Column("GoodsBrandId");

            mapping.HasMany(c => c.GoodsProducts);
            mapping.HasMany(c => c.GoodsImgs);
            mapping.HasMany(c => c.GoodsVideos);
            mapping.HasMany(c => c.GoodsStoreCategories);
            mapping.HasMany(c => c.Shippings);
            mapping.HasMany(c => c.VirtualCards);
            mapping.HasMany(c => c.AttrValues);
        }
    }
}